/**
 * 
 */
package com.google.code.jkippt.resource;

import java.util.Calendar;

import com.google.code.jkippt.annotation.Experimental;
import com.google.gson.annotations.SerializedName;

/**
 * @author Federico De Faveri defaveri@gmail.com
 *
 */
public class Clip extends ApplicationResource {

	protected String url;
	
	@SerializedName("url_domain")
	protected String urlDomain;
	protected User user;
	protected String title;
	protected ClipList list;
	protected String via;
	protected String notes;
	protected Countable<Comment> comments;
	protected Countable<User> likes;
	protected Countable<User> saves;
	
	@SerializedName("is_favorite")
	protected Boolean isFavorite;
	
	@SerializedName("favicon_url")
	protected String faviconUrl;
	protected Calendar updated;
	protected Calendar created;	

	//TODO unsupported Type and Media
	
	protected Clip(){}

	/**
	 * @param url the clip's uri.
	 */
	public Clip(String url) {
		this.url = url;
	}


	/**
	 * @param title the title to set
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * Sets the markdown formatted notes for the Clip
	 * @param notes the notes to set
	 */
	public void setNotes(String notes) {
		this.notes = notes;
	}

	/**
	 * Sets the ClipList of the Clip.
	 * @param list the list to set
	 */
	public void setList(ClipList list) {
		this.list = list;
	}

	/**
	 * Returns the clip's title.
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * Return the clip's URL.
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}

	/**
	 * Returns the markdown formatted notes for the Clip.
	 * @return the notes
	 */
	public String getNotes() {
		return notes;
	}

	/**
	 * @return the updated
	 */
	public Calendar getUpdated() {
		return updated;
	}

	/**
	 * @return the created
	 */
	public Calendar getCreated() {
		return created;
	}

	/**
	 * Returns the domain of the URL.
	 * @return the urlDomain
	 */
	public String getUrlDomain() {
		return urlDomain;
	}

	/**
	 * Returns the resource uri of the original Clip if saved via feed etc.
	 * @return the via
	 */
	public String getVia() {
		return via;
	}

	/**
	 * Returns the resource_uri of the List.
	 * @return the list
	 */
	public ClipList getList() {
		return list;
	}

	/**
	 * @return the faviconUrl
	 * @experimental Experimental API: This API is still under development and is subject to change.
	 */
	@Experimental
	public String getFaviconUrl() {
		return faviconUrl;
	}

	/**
	 * Returns the creator of the clip.
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @return the comments
	 */
	public Countable<Comment> getComments() {
		return comments;
	}

	/**
	 * @return the likes
	 */
	public Countable<User> getLikes() {
		return likes;
	}

	/**
	 * @return the saves
	 */
	public Countable<User> getSaves() {
		return saves;
	}

	/**
	 * @return the isFavorite
	 */
	public Boolean getIsFavorite() {
		return isFavorite;
	}

	/** 
	 * {@inheritDoc} 
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("Clip [url=");
		builder.append(url);
		builder.append(", urlDomain=");
		builder.append(urlDomain);
		builder.append(", user=");
		builder.append(user);
		builder.append(", title=");
		builder.append(title);
		builder.append(", list=");
		builder.append(list);
		builder.append(", via=");
		builder.append(via);
		builder.append(", notes=");
		builder.append(notes);
		builder.append(", comments=");
		builder.append(comments);
		builder.append(", likes=");
		builder.append(likes);
		builder.append(", saves=");
		builder.append(saves);
		builder.append(", isFavorite=");
		builder.append(isFavorite);
		builder.append(", faviconUrl=");
		builder.append(faviconUrl);
		builder.append(", updated=");
		builder.append(updated);
		builder.append(", created=");
		builder.append(created);
		builder.append("]");
		return builder.toString();
	}	
}
